<template>
  <div class="content-header"><h2>关于 "{{ searchName }}" 搜索结果</h2><h2>{{ dataList.length }} 篇</h2></div>
  <div class="content">
    <div class="article" @click="toArticleDetails(item)" v-for="(item,index) in dataList" :key="index">
      <div class="article-title"><h3>{{item.articleTitle}}</h3></div>
      <div class="article_img">
        <div class="blog_area">
          <div class="article-contnet">{{ item.articleDescription }}</div>
        </div>
        <div class="blog_img">
          <img :src="item.articleImageurl">
        </div>
      </div>
      <div class="blogdetails_footer">
        <div class="category">
          <span class="label_title">分类:</span>
          <span class="sub_list">{{ item.category.categoryName }}</span>
        </div>
        <div class="tag">
          <span class="label_title iconfont iconbiaoqian">标签:</span>
          <span v-for="(tag,index) in item.tags" class="sub_list">{{ tag.tagName }}</span>
        </div>
        <div class="time">
          <span class="label_title iconfont iconshijian">时间:</span>
          <span class="sub_list"> {{ getTime(item.articleDate) }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {request} from "../../../axios";
export default {
  name: "SearchList",
  props:{
    dataList:'',
    searchName:'',
  },
  methods: {
    toArticleDetails(blog){
      this.$router.push({
        path:`/articledetails/${blog.articleId}`,
      })
    },
    getTime(time){
      let date = new Date(time);
      let y = date.getFullYear();
      let M = date.getMonth()>=10 ? date.getMonth(): "0" + date.getMonth();
      let d = date.getDate()>=10 ? date.getDate(): "0" + date.getDate();
      return y + "-" + M + "-" + d ;
    },
  }

}
</script>

<style scoped>
.content-header{
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  color: #000000;
  border-bottom: 3px #cccccc solid;
  box-shadow: 0 0 10px #cccccc;
}
.article{
  width: 60%;
  height: 220px;
  padding: 10px;
  background-color: #ddd;
  border-bottom: 1px solid #ccc;
  border-radius: 10px;
  margin: 50px auto;
  /*box-sizing: border-box;*/
  transition: all 1s ease;
}
.article_img{
  display: flex;
}
.content{
  cursor: pointer;
}
.content .article:nth-child(2n) .blog_img{
  order: -1;
}
.blog_area{
  width: 100%;
}
.blog_img{
  width: 260px;
  height: 140px;
  transform: translateY(-20px);
  box-shadow: 0 0 5px #03e9f4;
  border-radius: 5px;
  overflow: hidden;
}
.blog_img img{
  width: 100%;
  height: 100%;
}

.article:hover{
  transform: scale(1.1);
  box-shadow: 10px 10px 10px #cccccc;
}
.article-title{
  padding: .5rem;
  margin-bottom: .5rem;
  text-shadow: 3px 3px 5px rgba(0,0,0,.8);
  overflow: auto;
  border-bottom: 3px solid #03e9f4;
}
.content .article:nth-child(2n) .article-title h3{
   float: right;
}

.article-contnet{
  color:#555;
  font-size: 14px;
  text-shadow: 0 0 3px #F7F7F7;
  text-indent: 2em;
  padding: .5rem .2rem;
  padding-bottom: .8rem;
  margin-bottom: .5rem;
  height: 5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}
.blogdetails_footer{
  display: flex;
  justify-content: space-around;
  /*font-size: 14px;*/
}
span{
  font-size: 14px!important;
}
.label_title{
  display: inline-block;
  width: 50px;
  border-radius: 5px;
  padding: 0 3px;
  text-align: center;
  line-height: 20px;
  box-shadow: 0 0 10px #0077aa;
  background-color: #03e9f4;
  margin-right: 2px;
}
.sub_list {
  background-color: #1abc9c;
  border-radius: 5px;
  padding: 0 3px;
  margin-right: 2px;
  box-shadow: 0 0 10px #0077aa;
}
.tag,.category,.time{
  display: flex;
  justify-content: space-around;
  flex-wrap: nowrap;
}

@media only screen and (max-width: 960px) {
    .article{
      width: 90%;
    }
    .tag{
      display: none;
    }
}
</style>